//
//  Empty+For.swift
//  RaveLand
//
//  Created by zhuxuhong on 2021/4/30.
//  Copyright © 2021 CSLY. All rights reserved.
//

import BWListKit

extension Empty {
    public enum BWList {
        case TableView(component: Component)
        case CollectionView(component: Component)
        
        public enum Component {
            case header(height: CGFloat, data: EmptyDataWrapper?)
            case footer(height: CGFloat, data: EmptyDataWrapper?)
            case cell(height: CGFloat, data: EmptyDataWrapper?)
        }
    }
}

extension Empty.BWList {
    public var headerFooter: BWListHeaderFooter? {
        switch self {
        case .TableView(let component):
            switch component {
            case .header(let h, let d),
                 .footer(let h, let d):
                return .init(reuseId: TableEmptyHeaderFooter.RID, height: h, data: d)
            default: return nil
            }
            
        case .CollectionView(let component):
            switch component {
            case .header(let h, let d),
                 .footer(let h, let d):
                return .init(reuseId: CollectionEmptyHeaderFooter.RID, height: h, data: d)
            default: return nil
            }
        }
    }
    public var cell: BWListItem? {
        switch self {
        case .TableView(let component):
            switch component {
            case .cell(let h, let d):
                return .init(reuseId: TableEmptyCell.RID, height: h, data: d)
            default: return nil
            }
            
        case .CollectionView(let component):
            switch component {
            case .cell(let h, let d):
                return .init(reuseId: CollectionEmptyCell.RID, height: h, data: d)
            default: return nil
            }
        }
    }
}

extension Empty.BWList {
    public var register: BWListRegister {
        switch self {
        case .TableView(let component):
            switch component {
            case .header(_,_):
                return .init(style: .header, class: TableEmptyHeaderFooter.self)
            case .footer(_,_):
                return .init(style: .footer, class: TableEmptyHeaderFooter.self)
            case .cell(_,_):
                return .init(style: .cell, class: TableEmptyCell.self)
            }
            
        case .CollectionView(let component):
            switch component {
            case .header(_,_):
                return .init(style: .header, class: CollectionEmptyHeaderFooter.self)
            case .footer(_,_):
                return .init(style: .footer, class: CollectionEmptyHeaderFooter.self)
            case .cell(_,_):
                return .init(style: .cell, class: CollectionEmptyCell.self)
            }
        }
    }
}
